package com.xidian.GMS.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xidian.GMS.dto.Page;
import com.xidian.GMS.entity.Announcement;
import com.xidian.GMS.entity.EmploymentConsult;
import com.xidian.GMS.mapper.EmploymentConsultMapper;
import com.xidian.GMS.service.EmploymentConsultService;

@Service
public class EmploymentConsultServiceImpl implements EmploymentConsultService {

	@Autowired
	private EmploymentConsultMapper employmentConsultMapper;
	
	
	@Override
	public EmploymentConsult Insert(EmploymentConsult employmentConsult) {
   	  int rows = employmentConsultMapper.insert(employmentConsult);
		if( rows == 0){
			throw new RuntimeException("错误");
		}
          return employmentConsult;
    }
	

	@Override
	public boolean delete(int consultantid) {
        int x =  employmentConsultMapper.deleteByPrimaryKey(consultantid);
  	  if (x == 1) {
  	  	  return true;
	}
          return false;
    }	

	@Override
	public boolean update(EmploymentConsult employmentConsult) {
		 
           int temp = employmentConsultMapper.updateByPrimaryKeySelective(employmentConsult);
		
       	  if (temp == 1) {
      	  	  return true;
    	}
              return false;
        }
	@Override
	public Page getEmploymentConsult(int cur) {
		Page page = new Page(cur);
		
		int count = employmentConsultMapper.count();
		
		List<EmploymentConsult> accounts = employmentConsultMapper.findAll(page.getOffset(), page.getSize());
		
		page.setCount(count);
		page.setList(accounts);
		
		return page;
	}
}
